# -*-* encoding:UTF-8 -*-
# author : mengy
# date   : 2018/11/22

import smtplib
import re
from email.header import Header
from email.mime.text import MIMEText

sender = "1215012319@qq.com"
receivers = ["1215012319@qq.com","mengyanyuan@outlook.com"]

mail_host = "smtp.qq.com"
mail_port = 25
mail_pwd = "dishang0117/"

file = open("mail_body.html","r+")
body = file.read()
print "发送邮件的正文"
print body
file.close()

message = MIMEText(body,"html","utf-8")
message['From'] = Header("python 测试邮件","utf-8")
message['To'] = Header("接收者","utf-8")

subject = "Python SMTP 测试邮件"
message['Subject'] = Header(subject,"utf-8")

try:
    mailObj = smtplib.SMTP()
    mailObj.connect(mail_host,mail_port)
    mailObj.login(sender,mail_pwd)
    mailObj.sendmail(sender,receivers,message.as_string())
    print "邮件发送成功"
except Exception,e:
    print "邮件发送失败:",e